#pragma once

#include <cstdint>

namespace cyb
{

/*
 * Based on this blog post by Christer Ericson, http://realtimecollisiondetection.net/blog/?p=86
 *
 * SortKey layout:
 *	                   3               2               1               0
 *      fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210
 *      vvvvvlllllttppppppppppppppppppppppppppppdddddddddddddddddddddddd
 *          ^    ^ ^                           ^                       ^
 *          |    | |                           |                       |
 * Viewport-+    | +-Translucency      Program-+                 Depth-+
 *         Layer-+  
 */

struct SortKey
{
	uint64_t Encode() const;
	void Decode( const uint64_t key );

	uint32_t m_depth;		// FIXME: Should be signed, but it seems to mess up the encoding/decoding
	uint32_t m_program;
	uint8_t m_translucecy;
	uint8_t m_layer;
	uint8_t m_viewport;
};

}	// namespace cyb